<template>
  <div class="home_two">
    <div class="titlea">
      <p>{{gettime}} 日报表</p>
    </div>
    <el-table size="mini" :data="tableData" border style="width: 100%">
      <el-table-column prop="moduleName" label="彩种"></el-table-column>
      <el-table-column prop="issue" label="期数"></el-table-column>
      <el-table-column prop="quantity" label="笔数"></el-table-column>
      <el-table-column prop="totalBets" label="总投"></el-table-column>
      <el-table-column prop="profit" label="盈亏"></el-table-column>
    </el-table>
    <!-- 分页 -->
    <div>
      <!-- 分页 -->
      <el-pagination
        size="mini"
        class="pageNumage"
        @current-change="handleCurrentChange"
        background
        layout="prev, pager, next"
        :total="total"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
import { mapState } from "Vuex";
export default {
  name: "homeOne",
  data() {
    return {
      
      pageNum: 1,
      total: 0,
      gettime: "", //当前时间
      tableData: [],
      startTime: "",
      endTime: "",
      pritem: this.$route.query.titleid
    };
  },
  created() {
    this.fetchData();
    this.currentTime();
  },
   computed: {
    ...mapState(["typedt"]),
  },
  methods: {
    //   分页
    handleCurrentChange(val) {
      this.pageNum = val;
      this.fetchData();
    },
    currentTime() {
      setInterval(this.getTime, 500);
    },
    // 接口
    fetchData() {
      this.$api.post(
        this.$url.report,
        {
          pageNum: this.pageNum,
          pageSize: 5,
          module:this.typedt
        },
        res => {
          if (res.data.code == 200) {
            console.log(res.data,"日报表")
            this.tableData = res.data.data;
            this.total = res.data.count;
          } else {
            this.$message.error(res.data.msg);
          }
        }
      );
    },
    getTime() {
      var _this = this;
      let yy = new Date().getFullYear();
      let mm = new Date().getMonth() + 1;
      let dd = new Date().getDate();
      let hh = new Date().getHours();
      let mf =
        new Date().getMinutes() < 10
          ? "0" + new Date().getMinutes()
          : new Date().getMinutes();
      let ss =
        new Date().getSeconds() < 10
          ? "0" + new Date().getSeconds()
          : new Date().getSeconds();
      _this.gettime = yy + "-" + mm + "-" + dd;
    }
  },
  mounted() {}
};
</script>
<style lang="less" scoped>
// 历史账单
.home_two {
  width: 100%;
  .titlea {
    margin: 30px 10px;
    p {
      background: #eee;
      color: #000;
      line-height: 30px;
      padding-left: 20px;
      font-weight: 700;
      box-sizing: border-box;
    }
    span {
      padding: 0px 10px;
    }
  }
}
// 分页
.pageNumage {
  float: right;
  margin-top: 20px;
}
</style>
